#pragma once

class EnumList;

// {F8D4D61D-1F39-4e25-A36C-2AAA5371FA09}
DEFINE_GUID(IID_ICollection, 0xf8d4d61d, 0x1f39, 0x4e25, 0xa3, 0x6c, 0x2a, 0xaa, 0x53, 0x71, 0xfa, 0x9);

#undef INTERFACE
#define INTERFACE ICollection
DECLARE_INTERFACE_(INTERFACE, IDispatch)
{
    STDMETHOD(QueryInterface)(THIS_ REFIID, void **) PURE;
    STDMETHOD_(ULONG, AddRef)(THIS) PURE;
    STDMETHOD_(ULONG, Release)(THIS) PURE;
    STDMETHOD(GetTypeInfoCount)(THIS_ UINT *) PURE;
    STDMETHOD(GetTypeInfo)(THIS_ UINT, LCID, ITypeInfo **) PURE;
    STDMETHOD(GetIDsOfNames)(THIS_ REFIID, LPOLESTR *, UINT, LCID, DISPID *) PURE;
    STDMETHOD(Invoke)(THIS_ DISPID, REFIID, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *) PURE;
    STDMETHOD(Count)(THIS_ LONG *) PURE;
    STDMETHOD(Item)(THIS_ LONG, VARIANT *) PURE;
    STDMETHOD(_NewEnum)(THIS_ IUnknown **) PURE;
};

class RealICollection : public ICollection
{
public:
    RealICollection(EnumList *pList);
    ~RealICollection();
    HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppv);
    ULONG STDMETHODCALLTYPE AddRef();
    ULONG STDMETHODCALLTYPE Release();
    HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo);
    HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo);
    HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
    HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
        DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
    HRESULT STDMETHODCALLTYPE Count(LONG *pNum);
    HRESULT STDMETHODCALLTYPE Item(LONG index, VARIANT *pData);
    HRESULT STDMETHODCALLTYPE _NewEnum(IUnknown **pUnk);

private:
    DWORD m_count;
    EnumList *m_list;
};
